﻿using System.Linq;
using System.Windows;
using System.Windows.Input;
using System.Windows.Media;
using FM.Common;
using FM.Events;
using FM.录音.Events;
using FM.录音.Services;
using FM.录音.接口;
using FM.接口;
using Microsoft.Practices.Prism.Commands;
using Microsoft.Practices.Prism.Mvvm;
using Microsoft.Practices.Prism.PubSubEvents;
using Microsoft.Practices.Prism.Regions;
using Microsoft.Practices.Unity;
using NJT.扩展;

namespace FM.录音.ViewModels
{
    public class 电平表2ViewModel : BindableBase, I电平信号三段
    {
        private Brush _指针画笔;
        private double _左电平红;
        private double _左电平黄;
        private double _左电平绿;
        private double _右电平红;
        private double _右电平黄;
        private double _右电平绿;
      
        public 电平表2ViewModel()
        {
            _指针画笔 = Brushes.LimeGreen;
        }

        public Brush 指针画笔
        {
            get { return _指针画笔; }
            set {SetProperty(ref _指针画笔 ,value) ; }
        }

        public double 左电平红
        {
            get { return _左电平红; }
            set {SetProperty(ref _左电平红 ,value) ; }

        }

        public double 左电平黄
        {
            get { return _左电平黄; }
            set {SetProperty(ref _左电平黄 ,value) ; }
        }

        public double 左电平绿
        {
            get { return _左电平绿; }
            set {SetProperty(ref _左电平绿 ,value) ; }
        }

        public double 右电平红
        {
            get { return _右电平红; }
            set {SetProperty(ref _右电平红 ,value) ; }
        }

        public double 右电平黄
        {
            get { return _右电平黄; }
            set {SetProperty(ref _右电平黄 ,value) ; }
        }

        public double 右电平绿
        {
            get { return _右电平绿; }
            set {SetProperty(ref _右电平绿 ,value) ; }
        }

        public void 更新(I电平表 电平值)
        {
            var L = 电平值.左电平;
            var R = 电平值.右电平;
            左电平红 = ((L - 0.9) / 0.1).范围限制(0, 1);
            左电平黄 = ((L - 0.7) / 0.2).范围限制(0, 1);
            左电平绿 = ((L ) / 0.7).范围限制(0, 1);

            右电平红 = ((R - 0.9) / 0.1).范围限制(0, 1);
            右电平黄 = ((R - 0.7) / 0.2).范围限制(0, 1);
            右电平绿 = ((R) / 0.7).范围限制(0, 1);

        }
    }
}